[gd_scene load_steps=3 format=2]

[sub_resource type="GDScript" id=1]
script/source = "extends CharacterBody3D

const rot = 0.02
const speed = 5
const Gr = -80
var vel = Vector3()
var rot_x = 0
var rot_y = 0

var GUI_management: bool = false;

func _ready():
	Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)

func _physics_process(delta):
	var dir = Vector3()
	
	if Input.is_action_just_pressed(\"ui_cancel\"):
		GUI_management = !GUI_management
	if Input.is_action_just_pressed(\"gui_management\"):
		GUI_management = !GUI_management
	if GUI_management:
		Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) 
		return
	else:
		Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED);
	
		
	if Input.is_action_pressed(\"ui_left\"):
		dir.x = -1
	if Input.is_action_pressed(\"ui_right\"):
		dir.x = 1
	if Input.is_action_pressed(\"ui_up\"):
		dir.z = -1
	if Input.is_action_pressed(\"ui_down\"):
		dir.z = 1
		
	if dir:
		dir *= speed
		dir = dir.rotated(Vector3(0,1,0), rotation.y)
		
	vel.x = dir.x
	vel.z = dir.z
		
	vel.y = Gr * delta
	set_velocity(vel)
	set_up_direction(Vector3(0,1,0))
	move_and_slide()
	vel = velocity
	
func _input(event):
	if event is InputEventMouseMotion:
		rot_y = event.relative.x
		rot_x = event.relative.y
		if rot_x < -1:
			rot_x = -1
		if rot_x > 1:
			rot_x = 1
		rotate_y(-rot_y * 0.2 * rot)
		$playerCamera.rotate_x(-rot_x * rot)
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
"

[sub_resource type="CapsuleShape3D" id=2]
radius = 0.5
height = 1.8

[node name="player" type="CharacterBody3D"]
transform = Transform3D( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.431714, 1.32987, -19.282 )
script = SubResource( 1 )

[node name="playerCamera" type="Camera3D" parent="."]
transform = Transform3D( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.055528, 1.03321, 0.173412 )
keep_aspect = 0
far = 200.0

[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D( 1, 0, 0, 0, -1.62921e-07, -1, 0, 1, -1.62921e-07, 0, 0.162331, 0 )
shape = SubResource( 2 )
